
var CommonConverter = {
	
	/*订单业务状态代码转换为名称字符串*/
	toOrderBizStatusStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
			case "0": return "待支付";
			case "1": return "待审核";
			case "2": return "待出票";
			case "3": return "出票中";
			case "4": return "出票完成";
			case "5": return "已取消";
			default: return "未知"
		}
	},

	/*订单财务状态代码转换为名称字符串*/
	toOrderPayStatusStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
			case "1": return "收款待审核";
			case "2": return "已收款";
			case "3": return "待提现";
			case "4": return "提现待审核";
			case "5": return "提现待支付";
			case "6": return "已付款";
			default: return "未知"
		}
	},
	
	/*合同状态代码转换为名称字符串*/
	toContractStatusStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
			case "1": return "待审核";
			case "2": return "待支付";
			case "3": return "押金已收";
			case "4": return "合同中止";
			case "5": return "合同完成";
			case "6": return "合同退回";
			case "7": return "合同取消";
			default: return "未知"
		}
	},

	/*乘客性别代码转换为名称字符串*/
	toPassengerSexStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
			case "1": return "男";
			case "2": return "女";
			default: return "未知"
		}
	},

	/*乘客类型代码转换为名称字符串*/
	toPassengerTypeStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
			case "1": return "成人";
			case "2": return "儿童";
			case "3": return "婴儿";
			default: return "未知"
		}
	},

	/*乘客证件类型代码转换为名称字符串*/
	toPassengerDocTypeStr: function(n){
		if(n==null || n==undefined) return "其他";
		switch(n.toString()){
			case "1": return "身份证";
			case "2": return "护照";
			default: return "其他"
		}
	},
	/*采购商审核状态   state */
	buyerStateToStr: function(n){
		if(n==null || n==undefined) return "其他";
		switch(n.toString()){
			case "1": return "待审核"
			case "2": return "未通过";
			case "0": return "已通过";
			default: return "其他"
		}
	},

	/*航班舱位代码转换为名称字符串*/
	//Y(经济)/C(商务)/F(头等)
	toFlightCabinTypeStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "F": return "头等舱";
			case "C": return "商务舱";
			case "Y": return "经济舱";
			default: return "未知"
		}
	},

	/*结算方式代码转换为名称字符串*/
	toPayTypeStr: function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "0": return "现金";
			case "1": return "支票";
			case "2": return "电汇";
			case "3": return "对公汇款";
			case "4": return "对私汇款";
			case "5": return "现金支票";
			case "6": return "转账支票";
			default: return "未知"
		}
	},
	toBankStr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "1": return "上海浦东发展银行股份有限公司天津科技支行";
			default: return "未知"
		}
	},
	/*交易类型代码转换成名称字符串*/
	toTradeStr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "0": return "票款";
			case "1": return "押金";
			case "2": return "提现";
			case "3": return "充值";
			default: return "未知"
		}
	},
	/*支付方式大妈转换成名称字符串*/
	toPaystr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "0": return "线下支付";
			default: return "未知"
		}
	},
	/*充值订单状态转换成名称字符串*/
	toRechargestr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "-1": return "审核不通过";
			case "0": return "待审核";
			case "1": return "已充值";
			default: return "未知"
		}
	},
	/*提现订单状态转换成名称字符串*/
	toWithdrawstr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "-1": return "审核不通过";
			case "0": return "待审核";
			case "1": return "待支付";
			case "2": return "已付款";
			default: return "未知"
		}
	},
	/*交易类型转换成名称字符串*/
	toTradeType:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString().toUpperCase()){
			case "0": return "票款";
			case "1": return "冻结";
			case "2": return "提现";
			case "3": return "充值";
			case "4": return "解冻";
			default: return "未知"
		}
	},
	/*提现(充值)审核状态换成名称字符串
	 * 审核状态（-1-未通过,0-待审核,1-已充值/待支付,2-已付款）
	 * */
	toWithdrawRecordStr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
		case "-1": return "审核未通过";
		case "0": return "待审核";
		case "1": return "待支付";
		case "2": return "已付款";
		default: return "未知"
		}
	},
	toRechargeRecordStr:function(n){
		if(n==null || n==undefined) return "未知";
		switch(n.toString()){
		case "-1": return "审核未通过";
		case "0": return "待审核";
		case "1": return "待支付";
		case "2": return "已付款";
		default: return "未知"
		}
	},
	/*转换金额为保留两位小数的格式(进位)*/
	formatMoney: function(money){
		if(money==undefined || isNaN(money)) { money=0;}
		return parseFloat(money).toFixed(2);
	},

	//封装函数  实现强制转换成两位小数的功能(	不进位)
	toPoint2 : function(a){
	    var aNew;
	    var re = /([0-9]+.[0-9]{2})[0-9]*/;
	    aNew = a.replace(re,"$1");
	 	return aNew;
	},
	
	/*格式化航班时刻为5位长度的hh:mm形式，或空字符串*/
	formatFlightTime:function(t){
		if(t==undefined || t==null) {return "";}
		if(t.length==5) {return t;}
		return t.substr(0,5);
	},

	//封装函数  实现若值为null或undefined 转化为未知
	toEmptyString: function(string){
		if(string == null || string == undefined || string == ""){
			return "未知";
		}else{
			return string
		};
	},
	//封装函数  实现若值为null或undefined 转化为空
	toNullString: function(string){
		if(string == null || string == undefined){
			return "";
		}else{
			return string
		};
	},
	//封装函数  实现若值为null或undefined 转化为0
	toZero: function(string){
		if(string == null || string == undefined || string == ""){
			return 0;
		}else{
			return string
		};
	},
	
	//封装函数  若是0  返回空字符
	toEmptyStr:function(string){
		if(string == null || string == undefined || string == "" || string == 0){
			return "";
		}else{
			return string
		};
	}
	
};

